$(function() {
	
	loadonline(); 
});

var dom1 = null;
var myChart1 = null;

var json1 = {
		name: [],
		value: []
	};

function loadonline() {
	 var obj = {};
     obj.dprtcode =  $("#dprtcode").val();
     
$.ajax({
    cache: true,
    type: "POST",
    url: ctx + "getLoadonline",
    async: false,
    data: obj,
    error: function (request) {
        $.modal.alertError("系统错误");
    },
    success: function (data) {
    	dom1 = document.getElementById("container1");
    	myChart1 = echarts.init(dom1);
        json = {
        		name: [],
        		value: []
        };
    
        if (data.length > 0) { 
        		 $.each(data, function (index, row) {
        			 json1.name.push(row.name);
        			 
                 })
                 json1.value=data;
        }
        
        initecharts1();
    }
});
	
}

function initecharts1() {
	
	 option1 = null;
	    option1 = {
    		 tooltip: {
  		        trigger: 'item',
  		        formatter: "{b}[ 库房数量: {c} ({d}%)]"
  		    },
//	        legend: {
//	            x : 'center',
//	            y : 'bottom',
//	            itemWidth: 8,
//	            itemHeight: 8,
//	            textStyle:{//图例文字的样式
//	                color:'#fff',
//	                fontSize:10
//	            },
//	            data:json1.name
//	        },
	        calculable : true,
	        color:['#ff7800','#23eb6a','#7627cb','#fffc00','#46afdb'],
	        series : [
	            {
	                name:'站点分布',
	                type:'pie',
	                radius : [30, 100],
	                center : ['50%', '50%'],
	                roseType : 'area',
	                labelLine: {    //图形外文字线
	                    normal: {
	                        length: 15,
	                        length2:15,
	                    }

	                },
	    	        label: {
	                    normal: {
	                        formatter: ' {b|{b}({c})} ',       //图形外文字上下显示
	                        borderWidth: 20,
	                        borderRadius: 4,
	                        padding: [0, 0],          //文字和图的边距
	                        rich: {
	                            b: {                        //name 文字样式
	                                fontSize: 11,
	                                lineHeight: 20,
	                                color: '#e25035'
	                            },
	                           
	                        }
	                    }
	                },
	                data:json1.value,
	            }
	        ]
	    };
	    ;
	    if (option1 && typeof option1 === "object") {
	        myChart1.setOption(option1, true);
	    }
}